home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / GraphicsCards / StormMesa / src-glut / glut_ext.c < prev    next >
C/C++ Source or Header  |  1998-12-15  |  1KB  |  54 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994, 1997. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <stdlib.h>
  9. #include <string.h>
  10.  
  11. #include "glutint.h"
  12.  
  13. /* CENTRY */
  14. int APIENTRY 
  15. glutExtensionSupported(const char *extension)
  16. {
  17.   static const GLubyte *extensions = NULL;
  18.   const GLubyte *start;
  19.   GLubyte *where, *terminator;
  20.  
  21.   /* Extension names should not have spaces. */
  22.   where = (GLubyte *) strchr(extension, ' ');
  23.   if (where || *extension == '\0')
  24.     return 0;
  25.  
  26.   if (!extensions) {
  27.     extensions = glGetString(GL_EXTENSIONS);
  28.   }
  29.   /* It takes a bit of care to be fool-proof about parsing the
  30.      OpenGL extensions string.  Don't be fooled by sub-strings,
  31.      etc. */
  32.   start = extensions;
  33.   for (;;) {
  34.     /* If your application crashes in the strstr routine below,
  35.        you are probably calling glutExtensionSupported without
  36.        having a current window.  Calling glGetString without
  37.        a current OpenGL context has unpredictable results.
  38.        Please fix your program. */
  39.     where = (GLubyte *) strstr((const char *) start, extension);
  40.     if (!where)
  41.       break;
  42.     terminator = where + strlen(extension);
  43.     if (where == start || *(where - 1) == ' ') {
  44.       if (*terminator == ' ' || *terminator == '\0') {
  45.         return 1;
  46.       }
  47.     }
  48.     start = terminator;
  49.   }
  50.   return 0;
  51. }
  52.  
  53. /* ENDCENTRY */
  54.